// 统一请求路径前缀在libs/axios.js中修改
import {
  getRequest,
  postRequest,
  formRequest,
  putRequest,
  deleteRequest,
  uploadFileRequest
} from "@/libs/axios";

// 文件上传接口
export const uploadFile = "/xboot/upload/file";
// 验证码渲染图片接口
export const drawCodeImage = "/xboot/common/captcha/draw/";
// 获取菜单
export const getMenuList = "/xboot/permission/getMenuList";
// 获取数据字典
export const getDictData = "/xboot/dictData/getByType/";

// 登陆
export const login = params => {
  return formRequest("/sys/login", params);
};
export const getMenuNav = params => {
  return getRequest("/sys/menu/nav", params);
};

// 获取用户登录信息
export const userInfo = params => {
  return getRequest("/sys/user/info", params);
};
// 个人中心编辑
export const userInfoEdit = params => {
  return postRequest("/user/edit", params);
};
// 个人中心修改密码
export const changePass = params => {
  return postRequest("/sys/user/password", params);
};
// 解锁
export const unlock = params => {
  return postRequest("/user/unlock", params);
};

// 获取全部权限数据
export const getAllMenuList = params => {
  return getRequest("/sys/menu/list1", params);
};
// 添加权限
export const addMenu = params => {
  return postRequest("/sys/menu/save", params);
};
// 编辑权限
export const editMenu = params => {
  return postRequest("/sys/menu/update", params);
};
// 删除权限
export const deleteMenu = params => {
  return postRequest("/sys/menu/delete", params);
};

// 获取用户数据 多条件
export const getUserListData = params => {
  return getRequest("/user/getByCondition", params);
};

export const getUserPageList = params => {
  return getRequest("/sys/user/list", params);
};
export const getRoleSelect = params => {
  return getRequest("/sys/role/select", params);
};

// 获取全部用户数据
export const getAllUserData = params => {
  return getRequest("/user/getAll", params);
};
// 添加用户
export const addUser = params => {
  return postRequest("/sys/user/save", params);
};
// 编辑用户
export const editUser = params => {
  return postRequest("/sys/user/update", params);
};
// 删除用户
export const deleteUser = params => {
  return postRequest("/sys/user/delete", params);
};
// 重置用户密码
export const resetUserPass = params => {
  return postRequest("/sys/user/resetpwd", params);
};

/**
 * 获取个人信息
 * @param id
 * @returns {*}
 */
export const getUserInfo = id => {
  if (id) {
    return getRequest("/sys/user/info/" + id.toString());
  } else {
    return getRequest("/sys/user/info");
  }
};

// 获取全部角色数据
export const getAllRoleList = params => {
  return getRequest("/role/getAllList", params);
};
// 分页获取角色数据
export const getRolePageList = params => {
  return getRequest("/sys/role/list", params);
};
// 添加角色
export const addRole = params => {
  return postRequest("/sys/role/save", params);
};
// 编辑角色
export const editRole = params => {
  return postRequest("/sys/role/update", params);
};
// 获取角色的详细信息
export const getRoleInfo = params => {
  return getRequest("/sys/role/info/" + params.toString());
};
// 分配角色权限
export const editRolePerm = params => {
  return postRequest("/sys/role/perms", params);
};
// 分配角色数据权限
export const editRoleDep = params => {
  return postRequest("/sys/role/update", params);
};
// 删除角色
export const deleteRole = params => {
  return postRequest("/sys/role/delete", params);
};

// 获取全部权限数据
export const getAllPermissionList = params => {
  return getRequest("/permission/getAllList", params);
};
// 添加权限
export const addPermission = params => {
  return postRequest("/permission/add", params);
};
// 编辑权限
export const editPermission = params => {
  return postRequest("/permission/edit", params);
};
// 删除权限
export const deletePermission = (ids, params) => {
  return deleteRequest(`/permission/delByIds/${ids}`, params);
};
// 搜索权限
export const searchPermission = params => {
  return getRequest("/permission/search", params);
};

// 获取绑定账号信息
export const relatedInfo = (username, params) => {
  return getRequest(`/relate/getRelatedInfo/${username}`, params);
};
// 解绑账号
export const unRelate = params => {
  return postRequest("/relate/delByIds", params);
};
// 分页获取绑定账号信息
export const getRelatedListData = params => {
  return getRequest("/relate/findByCondition", params);
};

// 获取一级部门
export const initDepartment = params => {
  return getRequest("/sys/dept/list", params);
};
// 加载部门子级数据
export const loadDepartment = (id, params) => {
  return getRequest(`/department/getByParentId/${id}`, params);
};
// 添加部门
export const addDepartment = params => {
  return postRequest("/sys/dept/save", params);
};
// 编辑部门
export const editDepartment = params => {
  return postRequest("/sys/dept/update", params);
};
// 删除部门
export const deleteDepartment = params => {
  return postRequest("/sys/dept/delete", params);
};
//级联部门
export const getDeptCascader = params => {
  return getRequest("/sys/dept/cascader", params);
};
// 搜索部门
export const searchDepartment = params => {
  return getRequest("/department/search", params);
};

//定时任务
export const getSchedulePageList = params => {
  return getRequest("/sys/schedule/list", params);
};

export const addSchedule = params => {
  return postRequest("/sys/schedule/save", params);
};
export const updateSchedule = params => {
  return postRequest("/sys/schedule/update", params);
};
export const deleteSchedule = params => {
  return postRequest("/sys/schedule/delete", params);
};
export const pauseSchedule = params => {
  return postRequest("/sys/schedule/pause", params);
};
export const resumeSchedule = params => {
  return postRequest("/sys/schedule/resume", params);
};
export const runSchedule = params => {
  return postRequest("/sys/schedule/run", params);
};

// 获取全部字典
export const getAllDictList = params => {
  return getRequest("/dict/getAll", params);
};
// 添加字典
export const addDict = params => {
  return postRequest("/dict/add", params);
};
// 编辑字典
export const editDict = params => {
  return postRequest("/dict/edit", params);
};
// 删除字典
export const deleteDict = (ids, params) => {
  return deleteRequest(`/dict/delByIds/${ids}`, params);
};
// 搜索字典
export const searchDict = params => {
  return getRequest("/dict/search", params);
};
// 获取全部字典数据
export const getAllDictDataList = params => {
  return getRequest("/dictData/getByCondition", params);
};
// 添加字典数据
export const addDictData = params => {
  return postRequest("/dictData/add", params);
};
// 编辑字典数据
export const editDictData = params => {
  return postRequest("/dictData/edit", params);
};
// 删除字典数据
export const deleteData = (ids, params) => {
  return deleteRequest(`/dictData/delByIds/${ids}`, params);
};
// 通过类型获取字典数据
export const getDictDataByType = (type, params) => {
  return getRequest(`/dictData/getByType/${type}`, params);
};

// 分页获取日志数据
export const getLogListData = params => {
  return getRequest("/log/getAllByPage", params);
};
// 删除日志
export const deleteLog = (ids, params) => {
  return deleteRequest(`/log/delByIds/${ids}`, params);
};
// 清空日志
export const deleteAllLog = params => {
  return deleteRequest("/log/delAll", params);
};

// 分页获取Redis数据
export const getRedisData = params => {
  return getRequest("/redis/getAllByPage", params);
};
// 通过key获取Redis信息
export const getRedisByKey = (key, params) => {
  return getRequest(`/redis/getByKey/${key}`, params);
};
// 获取Redis键值数量
export const getRedisKeySize = params => {
  return getRequest("/redis/getKeySize", params);
};
// 获取Redis内存
export const getRedisMemory = params => {
  return getRequest("/redis/getMemory", params);
};
// 获取Redis信息
export const getRedisInfo = params => {
  return getRequest("/redis/info", params);
};
// 添加编辑Redis
export const saveRedis = params => {
  return postRequest("/redis/save", params);
};
// 删除Redis
export const deleteRedis = params => {
  return deleteRequest("/redis/delByKeys", params);
};
// 清空Redis
export const deleteAllRedis = params => {
  return deleteRequest("/redis/delAll", params);
};

// 分页获取定时任务数据
export const getQuartzListData = params => {
  return getRequest("/quartzJob/getAllByPage", params);
};
// 添加定时任务
export const addQuartz = params => {
  return postRequest("/quartzJob/add", params);
};
// 编辑定时任务
export const editQuartz = params => {
  return postRequest("/quartzJob/edit", params);
};
// 暂停定时任务
export const pauseQuartz = params => {
  return postRequest("/quartzJob/pause", params);
};
// 恢复定时任务
export const resumeQuartz = params => {
  return postRequest("/quartzJob/resume", params);
};
// 删除定时任务
export const deleteQuartz = (ids, params) => {
  return deleteRequest(`/quartzJob/delByIds/${ids}`, params);
};

// 分页获取消息数据
export const getMessageData = params => {
  return getRequest("/message/getByCondition", params);
};
// 添加消息
export const addMessage = params => {
  return postRequest("/message/add", params);
};
// 编辑消息
export const editMessage = params => {
  return postRequest("/message/edit", params);
};
// 删除消息
export const deleteMessage = (ids, params) => {
  return deleteRequest(`/message/delByIds/${ids}`, params);
};
// 分页获取消息推送数据
export const getMessageSendData = params => {
  return getRequest("/messageSend/getByCondition", params);
};
// 编辑发送消息
export const editMessageSend = params => {
  return putRequest("/messageSend/update", params);
};
// 删除发送消息
export const deleteMessageSend = (ids, params) => {
  return deleteRequest(`/messageSend/delByIds/${ids}`, params);
};

/**
 * 获取运营商列表数据
 * @param params
 * @returns {*}
 */
export const getOperatorsPageList = params => {
  return getRequest("/bss/operator/list", params);
};
/**
 * 添加运营商
 * @param params
 * @returns {*}
 */
export const addOperators = params => {
  return postRequest("/bss/operator/save", params);
};

/**
 * 删除运营商
 * @param params
 * @returns {*}
 */
export const deleteOperators = params => {
  return postRequest("/bss/operator/delete", params);
};
/**
 * 更新运营商
 * @param params
 * @returns {*}
 */
export const updateOperators = params => {
  return postRequest("/bss/operator/update", params);
};

/**
 * 获取企业运输管理列表数据
 * @param params
 * @returns {*}
 */
export const getCompanyPageList = params => {
  return getRequest("/bss/company/list", params);
};
/**
 * 添加企业运输管理
 * @param params
 * @returns {*}
 */
export const addCompany = params => {
  return postRequest("/bss/company/save", params);
};

/**
 * 删除企业运输管理
 * @param params
 * @returns {*}
 */
export const deleteCompany = params => {
  return postRequest("/bss/company/delete", params);
};
/**
 * 更新运营商
 * @param params
 * @returns {*}
 */
export const updateCompany = params => {
  return postRequest("/bss/company/update", params);
};

/**
 * 获取驾驶员列表数据
 * @param params
 * @returns {*}
 */
export const getDriverPageList = params => {
  return getRequest("/bss/client/list", params);
};
/**
 * 添加驾驶员
 * @param params
 * @returns {*}
 */
export const addDriver = params => {
  return postRequest("/bss/client/save", params);
};

/**
 * 删除驾驶员
 * @param params
 * @returns {*}
 */
export const deleteDriver = params => {
  return postRequest("/bss/client/delete", params);
};
/**
 * 更新驾驶员
 * @param params
 * @returns {*}
 */
export const updateDriver = params => {
  return postRequest("/bss/client/update", params);
};

/**
 * 获取企业下拉列表
 * @param params
 * @returns {*}
 */
export const getCompanyCombo = params => {
  return postRequest("/bss/company/combo", params);
};

// base64上传
export const base64Upload = params => {
  return postRequest("/upload/file", params);
};

/*
 *首页
 */
export const getHomeSum = params => {
  return getRequest("/bss/home/sum", params);
};
export const getHomeArea = params => {
  return getRequest("/bss/home/area", params);
};
export const getHomeChart = params => {
  return getRequest("/bss/home/chart", params);
};

/*
 * 获取规则列表
 */
export const getRuleList = params => {
  return getRequest("/bss/rule/list", params);
};

/**
 * 添加规则
 * @param params
 * @returns {*}
 */
export const addRule = params => {
  return postRequest("/bss/rule/save", params);
};

/**
 * 删除规则
 * @param params
 * @returns {*}
 */
export const deleteRule = params => {
  return postRequest("/bss/rule/delete", params);
};

/**
 * 修改规则
 * @param params
 * @returns {*}
 */
export const updateRule = params => {
  return postRequest("/bss/rule/update", params);
};

/**
 * 分配规则
 * @param params
 * @returns {*}
 */
export const assignRules = params => {
  return postRequest("/bss/rule/assign", params);
};

/**
 * 查岗记录
 * @param params
 * @returns {*}
 */
export const getOverseeList = params => {
  return getRequest("/bss/oversee/list", params);
};
export const answerOversee = params => {
  return postRequest("/bss/oversee/answer", params);
};
